<template>
    <div class="box">
        <div class="title">
            <p>年龄比例</p>
            <img src="../../images/dataScreen-title.png" />
        </div>
        <div class="charts" ref="chartsRef"></div>
    </div>
</template>

<script setup lang='ts' name='Age'>
import * as echarts from 'echarts'
const chartsRef = ref()

onMounted(() => {
    const myChart = echarts.init(chartsRef.value)
    myChart.setOption({
        tooltip: {
            trigger: 'item'
        },
        legend: {
            top: 'middle',
            orient: 'vertical',
            right: '40',
            textStyle: {
                color: 'white',
                fontSize: 16
            }
        },
        series: [
            {
                name: '男女比例',
                type: 'pie',
                left: '-20%',
                top: '-10%',
                bottom: '-10%',
                right: 0,
                clockwise: false,
                radius: ['40%', '70%'],
                avoidLabelOverlap: false,
                itemStyle: {
                    borderRadius: 10,
                    borderColor: '#fff',
                    borderWidth: 2
                },
                label: {
                    show: true,
                    position: 'inside',
                    color: 'white',
                    fontSize: 16,

                },
                labelLine: {
                    show: false
                },
                data: [
                    { value: 1048, name: '15-24岁' },
                    { value: 735, name: '24-36岁' },
                    { value: 580, name: '36岁以上' },
                    { value: 484, name: '0-15岁' },
                ]
            }
        ]
    })
})
</script>

<style scoped lang='scss'>
.box {
    width: 100%;
    height: 100%;
    background: url(../../images/dataScreen-main-cb.png) no-repeat;
    background-size: 100% 100%;
    margin: 10px 0px;

    .title {
        margin-left: 10px;

        p {
            color: white;
            font-size: 20px;
            margin-top: 20px;
        }
    }

    .charts {
        width: 100%;
        height: 230px;
    }
}
</style>